package com.example.sys.attachment.service;

import com.example.sys.attachment.po.SysAttachment;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;

@Service
public class SysAttachmentUpLoadListenerServiceImpl implements SysAttachmentUpLoadListenerService {

    @Resource
    private List<SysAttachmentUpLoadListener> sysAttachmentUpLoadListeners = new ArrayList<>();

    @Override
    public SysAttachment upLoad(HttpServletRequest request, SysAttachment sysAttachment, byte[] bytes) throws Exception {
        for (SysAttachmentUpLoadListener sysAttachmentUpLoadListener : this.sysAttachmentUpLoadListeners) {
            sysAttachmentUpLoadListener.onListener(request, sysAttachment, bytes);
        }
        return sysAttachment;
    }
}
